﻿@{
    ViewBag.Title = "工资公式";
}
@section header{

}
<form id="form1">
    <div class="form-layout">
        <input type="hidden" id="ID" name="ID" value="" />
        <input type="hidden" id="IfType" name="IfType" value="0" />
        <input type="hidden" id="ParentID" name="ParentID" value="" />
        <table class="form">
            <tr>
                <th class="formTitle">名称</th>
                <td class="formValue">
                    <input id="Name" name="Name" type="text" class="form-control required" autocomplete="off" />
                </td>
            </tr>
            <tr id="tr_SalaryType" name="tr_SalaryType">
                <th class="formTitle">计算类型</th>
                <td class="formValue">
                    <select id="SalaryType" name="SalaryType" class="form-control required">
                        <option value="1">公式调用</option>
                        <option value="2">直接输入</option>
                        <option value="3">固定工资</option>
                        <option value="4">其它导入</option>
                    </select>
                </td>
            </tr>
            <tr id="tr_OperateExpression" name="tr_OperateExpression">
                <th class="formTitle">公式</th>
                <td class="formValue">
                    <textarea id="OperateExpression" name="OperateExpression" class="form-control required" style="height: 60px;"></textarea>
                </td>
            </tr>
            <tr>
                <th class="formTitle">备注</th>
                <td class="formValue">
                    <textarea id="Remark" name="Remark" class="form-control" style="height: 60px;"></textarea>
                </td>
            </tr>
        </table>
    </div>
</form>

@section scripts{
    <script>
        var baseUrl = "/reward/SalaryColumn/";
        var keyValue = $.request("keyValue");
        var IfType = $.request("IfType");
        var ParentID = $.request("ParentID");
        $(function () {
            initControl();
        });
        function initControl() {
            if (!!keyValue) {
                $.ajax({
                    url: baseUrl + "GetFormJson",
                    data: { keyValue: keyValue },
                    dataType: "json",
                    success: function (data) {
                        $("#form1").formSerialize(data);
                    }
                });
            }
            $("#IfType").val(IfType);
            if (IfType == "1") {
                $("#tr_SalaryType").hide();
                $("#tr_OperateExpression").hide();
            } else {
                $("#tr_SalaryType").show();
                $("#tr_OperateExpression").show();
                $("#ParentID").val(ParentID);
            }
        }
        function submitForm() {
            if (!$('#form1').formValid()) {
                return false;
            }
            $.submitForm({
                url: baseUrl + "SubmitForm?keyValue=" + keyValue,
                param: $("#form1").formSerialize(),
                success: function () {
                    $.currentWindow().$("#gridList").resetSelection();
                    $.currentWindow().$("#gridList").trigger("reloadGrid");
                }
            })
        }
    </script>
}